<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="vue.js"></script>
</head>

<body>
  <div id="app"></div>

  <script>
    // 生命周期函数：就是vue实例在某个时间点会自动执行的函数
    var vm = new Vue({
      el: "#app",
      template:"<div>{{msg}}</div>",
      data: {
        msg:"hello world"
      },
      beforeCreate: function() { // 初始化完成前
        console.log('beforeCreate 创建前状态');
      },
      created: function() { // 初始化完成后
        console.log('created 创建完毕状态');
      },
      beforeMount: function() { 
        console.log(this.$el);
        console.log('beforeMount 挂载前状态');
      },
      mounted: function () {
        console.log(this.$el);
        console.log('mounted 挂载结束状态');
      },
      beforeDestroy: function () { // 通过vm.$destory()实现执行
        console.log('beforeDestory 销毁前状态');
      },
      destroyed: function () {
        console.log('destoryed 销毁后状态');
      },
      beforeUpdate: function () { 
        console.log('beforeUpdate 更新前状态');
      },
      updated: function () {
        console.log('updated 更新结束状态');
      }
    })

  </script>

</body>

</html>